//http://www.yto.net.cn/service/pl_sql.aspx?NumberText=2229907179&CodeText=9276
function serach(btn){
	var resComp=null;
	var info=null;
	var errObj={errFlag:false,errMessage:''};
	if(btn.type=="zto"){
			var billno=Ext.getCmp("zto_no").getValue();
			if(billno.trim()=="")return ;
			var info=getZtoInfo_json(billno);
			
	}else if(btn.type=="sto"){
			var billno=Ext.getCmp("sto_no").getValue();
			if(billno.trim()=="")return ;
			var info=getStoInfo_json(billno);
			
	}else if(btn.type=="yto"){
			var billno=Ext.getCmp("yto_no").getValue();
			if(billno.trim()=="")return ;
			var code=Ext.getCmp("yto_code").getValue();
			var info=getYtoInfo_json(billno,code);
	}else if(btn.type=="sf"){
			var billno=Ext.getCmp("sf_no").getValue();
			if(billno.trim()=="")return ;
			var code=Ext.getCmp("sf_code").getValue();
			var info=getSfInfo_json(billno,code);
	}
	if(info.err){
		resComp=new Ext.form.Label({text:info.err});
	}else{
		var ds=new Ext.data.JsonStore({
						  autoDestroy: true,
					      root: 'records',
					      fields: ['date',  "track"] });
		ds.loadData(info,false);
		var sm = new Ext.grid.CheckboxSelectionModel({singleSelect : true });
		var cm=	new Ext.grid.ColumnModel({
								columns : [new Ext.grid.RowNumberer(), {
											header : '时间',
											dataIndex : 'date'
										},{
											header : '跟踪记录',
											dataIndex : 'track'}]
							});
		resComp=new Ext.grid.EditorGridPanel({
 								sm : sm,
								cm : cm,
								clicksToEdit : 1,
								store : ds,
								enableHdMenu:false,
								forceValidation : true,
								disableSelection : true,
								autoHeight:true,
								//height:200,
							 	viewConfig: {forceFit:true}, 
								loadMask : true });
	}
	new Ext.Panel({
			title:"【"+billno+"】",
	 		renderTo:'bb',
	 		id:'infoPan',
	 		border:false,
	 		items:[resComp]
		});
}
Ext.onReady(function(){
	  document.getElementById("bb").style.height=document.body.clientHeight-60;
	 new Ext.FormPanel({
	 	layout : 'column',
	 		title:"快递跟踪",
	 		labelSeparator : ':',
   			renderTo:'aa',
   		//	width:800,
   			labelAlign :'right',
   			labelWidth:60,
   			 style:"float:left;",
			defaults : {
				layout : 'form',
				border : false,
				columnWidth : .2
			},
   			items:[ {layout:'column',border:true,items:[new Ext.form.TextField({fieldLabel:"中通单号",allowBlank:false,emptyText:'请输入中通单号',id:'zto_no'}),new Ext.Button({text:"中通查询",type:'zto',handler:serach})]},
   					{layout:'column',border:true,items:[new Ext.form.TextField({fieldLabel:"申通单号",allowBlank:false,emptyText:'请输入申通单号',id:'sto_no'}),new Ext.Button({text:"申通查询",type:'sto',handler:serach})]},
   					{columnWidth : .3, style:"float:left;",layout:'column',border:true,items:[new Ext.form.TextField({fieldLabel:"圆通单号",allowBlank:false,emptyText:'请输入圆通单号',id:'yto_no'}),{style:"float:left;",width:46,html:'<img src="http://www.yto.net.cn/link/CreateValidCode.aspx"  onclick="this.src=\'http://www.yto.net.cn/link/CreateValidCode.aspx?time=\'+Math.random()" />'}
   					,new Ext.form.TextField({fieldLabel:"中通单号",emptyText:'请输入验证码',id:'yto_code'}),new Ext.Button({text:"圆通查询",type:'yto',handler:serach})]},
   					{columnWidth : .3, style:"float:left;",layout:'column',border:true,items:[new Ext.form.TextField({fieldLabel:"顺丰单号",allowBlank:false,emptyText:'请输入顺丰单号',id:'sf_no'}),{style:"float:left;",width:55,html:'<img style="vertical-align:middle;width:55px;height:22px" src="http://www.sf-express.com/Countersign.aspx?CountersignName=CustomerRigester&r=0.001"  onclick="this.src=\'http://www.sf-express.com/Countersign.aspx?CountersignName=CustomerRigester&r=\'+Math.random()" />'}
   					,new Ext.form.TextField({fieldLabel:"顺丰单号",emptyText:'请输入验证码',id:'sf_code'}),new Ext.Button({text:"顺丰查询",type:'sf',handler:serach})]}
   									
   				]
		});
	 
});